package com.jinzhi.jzapi.certificate.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.type.ApiEnumError;
import com.jinzhi.common.utils.ApiResult;
import com.jinzhi.common.utils.Result;
import com.jinzhi.common.utils.ValidUtils;
import com.jinzhi.jzapi.certificate.pojo.OrgRolesListVo;
import com.jinzhi.jzweb.domain.CertificateProfileDO;
import com.jinzhi.jzweb.domain.ExaminationPointDO;
import com.jinzhi.jzweb.domain.OrganizationNewsDO;
import com.jinzhi.jzweb.domain.OrganizationRolesDO;
import com.jinzhi.jzweb.domain.TrainStudentInfoDO;
import com.jinzhi.jzweb.service.CertificateProfileService;
import com.jinzhi.jzweb.service.ExaminationPointService;
import com.jinzhi.jzweb.service.OrganizationNewsService;
import com.jinzhi.jzweb.service.OrganizationRolesService;
import com.jinzhi.jzweb.service.TrainStudentInfoService;
import com.jinzhi.sys.domain.UserDO;
import com.jinzhi.sys.service.UserRoleService;
import com.jinzhi.sys.service.UserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.*;

import static com.jinzhi.api.util.TokenTag.TOKEN_TAG;

@Slf4j
@Controller
@RequestMapping("/jzApi/trainSudentInfo")
public class ApiTrainStudentInfoController extends BaseController {

	@Autowired
	private TrainStudentInfoService trainStudentInfoService;


    @Log("提交编辑站点申请")
    @ResponseBody
    @PostMapping("/saveInfo")
    Result<String> saveStation(TrainStudentInfoDO t) {
    	if(!ValidUtils.isMobile(t.getMobile())){
    		return  Result.build(1,"手机号码格式不正确！");
    	}
    	if(!ValidUtils.isIDCard(t.getIdNumber())) {
    		return Result.build(1,"身份证格式不正确！");
    	}
    	if(!ValidUtils.isImage(t.getPicAddress())) {
    		return Result.build(1,"照片格式不正确！");
    	}
    	Map map = new HashMap();
    	map.put("idNumber",t.getIdNumber());
    	List<TrainStudentInfoDO> List = trainStudentInfoService.selectByMap(map);
    	if(List.size()>=1) {
    		return Result.build(1,"身份信息已存在！");
    	}
        trainStudentInfoService.insert(t);
    	return Result.ok();
    }
}
